<?php include_once '../../../include/inc_session.php';	

	if(isset($_GET['Identifiant_personne']) && !empty($_GET['Identifiant_personne']))
	{ // Vérifier si Identifiant_personne est passé en paramètre
		$idPersonne = $_GET['Identifiant_personne'];
	}
	$idRole = $_GET['idrole'];
	$idContrat = isset($_POST['Identifiant_contrat'])? $_POST['Identifiant_contrat']: $_GET['idcontrat'];
	
	$oContrat = new dataObject_contrat($idContrat);
	$oProduit = new dataObject_produit();
	$oGarSousc = new dataObject_garantieSouscrite();
	
	$aList = $oProduit->produit_getListGarantieOptionnelle($_SESSION['produit']);
	
	$nommodule2="Détail garantie";

	if ($gbFormValid) 
	{
		$oGarSousc->_ETAT_GAR_SOUSC 			= $aRow['Etat_garantie_souscrite'];
		$oGarSousc->_DATE_EFFET_GAR_SOUSC 	= $oContrat->_DATE_EFFET;
		$oGarSousc->_DATE_FIN_EFFET_GAR_SOUSC = $oContrat->_DATE_ECHEANCE;
		$oGarSousc->_IDENTIFIANT_CONTRAT  	= $idContrat;
		$oGarSousc->_IDENTIFIANT_PERSONNE  	= $idPersonne;
		$oGarSousc->_IDENTIFIANT_GARANTIE  	= $_POST['Identifiant_garantie'];
		$oGarSousc->_IDENTIFIANT_FORMULE  	= $_SESSION['formule'];
		
		$id = $oGarSousc->garantieSouscrite_insert();
		if(!$id) $oForm->ajouterErreur(chgmt_couv_crea_garopt_pbm);
		else $oForm->ajouterErreur(garantie_opt_creation);
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Garantie optionnelle</title>
<link rel="stylesheet" type="text/css" href="../../../css/main.css" />
<link rel="stylesheet" type="text/css" href="list.css" />

</head>
<body>
<div id="sf_menu1">
	<h3><?php echo $oBloc->_MENU_NOM ?></h3>
	<div id="information_erreur" class="false">
        <ul id="message">
        	<li><?php $aMsg =$oForm->getValidMessage(); echo (!empty($aMsg))? $aMsg[0]['message'] : ''; ?></li>
        </ul>
    </div>
    
</div>


<div class="corps1">
<div class="cleared"></div>
<div id="br"></div>
<!--/***************************************/-->
<form action="<?php echo $sEditFormAction; ?>" method="post" name="form2" id="form2">
	<div class="imgleft"></div>
	<div class="imgmiddle">
		<div class="btn">
        	<span class="btnleft"></span>
            <span class="btnmiddle">
            	<h5><?php echo $oFonction->_MENU_AFFICHE; ?></h5>
            </span><span class="btnright"></span>
        </div>
		<div class="btn1">
        	<span class="btnleft"></span>
            <span class="btnmiddle">
            	<h5><?php echo $nommodule2; ?></h5>
            </span><span class="btnright"></span>
        </div>
		<div class="cleared"></div>
	<div class="formulaire">
  <table class="tabform">
    <tr>
      <td >GARANTIE OPTIONNELLE </td>
      <td><select name="Identifiant_garantie">
<?php
	if (count($aList) > 0) 
	{ // Show if recordset not empty
		foreach($aList as $i => $aRow) 
	  	{
		
 ?>
        <option value="<?php echo $aRow['Identifiant_garantie']?>"><?php echo $aRow['Libelle_garantie']?></option>
        <?php
		} 
  	}
?>
      </select>
      </td>
     </tr>
  </table>
    
    </div>
    
 </div>


<div class="imgright"></div>
<?php
if(isset($_SESSION['visu']))
		$sUrlRetour = "../../changecouverture/intervenant_edit.php?Identifiant_personne=".$_GET['Identifiant_personne']."&idcontrat=".$idContrat."&idrole=".$idRole;
	else $sUrlRetour = "../edit_personne.php?Identifiant_personne=".$_GET['Identifiant_personne']."&idcontrat=".$idContrat."&idrole=".$idRole;
?>
    				
    <div class="bt"> <a href="<?php echo $sUrlRetour;?>"><span class="btleft"></span>
        <span class="btmiddle">Annuler</span>
        <span class="btright"></span>
    </a></div>
    
     
    
      <div class="bt">
	<span class="btleft"></span><input type="submit" value="Valider" class="resizeall btmiddle"/>
    <span class="btright"></span></div>
    
	
      
  
   <div class="cleared"></div>

  <input type="hidden" name="Identifiant_contrat" value="<?php echo $idContrat; ?>" />
  <input type="hidden" name="Identifiant_personne" value="<?php echo $idPersonne; ?>" />
  <input type="hidden" name="MM_insert" value="form1" />
</form> </div>
</body>
</html>
<?php
include_once PATH_INCLUDE.'inc_pied_page.php';

?>